﻿using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using Common;

public partial class _admin_root__controls_ctlNavBar : System.Web.UI.UserControl
{
    protected void Page_Load(object sender, EventArgs e)
    {
        if (!IsPostBack)
            NavigationBar();
    }

    public string NvaBar = "";

    #region Navigation 所属类别导航
    void NavigationBar()
    {
        DataTable dt = BLL.CommonBLL.Select("vw_System_CatalogBase", "*", " AND DeletionStateCode = 0 ORDER BY Sort ASC");

        if (dt != null && dt.Rows.Count > 0)
        {
            BuildNavigationStr(dt, RequestBase.GetQueryString("groupid"));
            BuildNavigationBar(NvaBar);
        }
        dt.Dispose();
    }
    /// <summary>
    /// 拼接当前类别目录字符串
    /// </summary>
    /// <param name="kindDS">数据集</param>
    /// <param name="kindCode">类别编码</param>
    void BuildNavigationStr(DataTable dt, string strCategoryNumber)
    {
        if (strCategoryNumber == "")
            return;

        DataRow dr = dt.Select("[Number] = '" + strCategoryNumber + "'")[0];

        NvaBar += "<a href=\"" + dr["PageUrl"].ToString().Trim() + "\">" + dr["CatalogName"].ToString().Trim() + "</a>";

        if (dr["Layer"].ToString() == "0" || string.IsNullOrEmpty(dr["ParentNumber"].ToString()))
            return;
        NvaBar += "|";
        BuildNavigationStr(dt, dr["ParentNumber"].ToString().Trim());
    }
    /// <summary>
    /// 合并当前类别目录字符串
    /// </summary>
    /// <param name="menuStr">当前位置目录字符串</param>
    void BuildNavigationBar(string _navBar)
    {
        string[] arryNav = _navBar.Split('|');
        NvaBar = "";
        for (int i = arryNav.Length; i > 0; i--)
        {
            if (arryNav[i - 1] != "")
                NvaBar += " &gt;&gt;&nbsp;&nbsp;" + arryNav[i - 1];
        }
    }
    #endregion
}
